package com.cennavi.bigdata.baotou.util;

import org.springframework.util.StringUtils;

public class WeatherCodeTools {
	/** 天气码 **/
	public String weatherCode(String weaCode){
		String weatherCode = "Sunny";
		switch (Integer.parseInt(weaCode.replace(".0", ""))) {
		case 0:
			weatherCode = "Sunny,晴";
			break;
		case 1:
			weatherCode = "Cloudy,多云";
			break;
		case 2:
			weatherCode = "Overcast,阴";
			break;
		case 3:
			weatherCode = "Shower,阵雨";
			break;
		case 4:
			weatherCode = "Thundershower,雷阵雨";
			break;
		case 5:
			weatherCode = "Thundershower with hail,雷阵雨伴有冰雹";
			break;
		case 6:
			weatherCode = "Sleet,雨夹雪";
			break;
		case 7:
			weatherCode = "Light rain,小雨";
			break;
		case 8:
			weatherCode = "Moderate rain,中雨";
			break;
		case 9:
			weatherCode = "Heavy rain,大雨";
			break;
		case 10:
			weatherCode = "Storm,暴雨";
			break;
		case 11:
			weatherCode = "Heavy storm,大暴雨";
			break;
		case 12:
			weatherCode = "Severe storm,特大暴雨";
			break;
		case 13:
			weatherCode = "Snow flurry,阵雪";
			break;
		case 14:
			weatherCode = "Light snow,小雪";
			break;
		case 15:
			weatherCode = "Moderate snow,中雪";
			break;
		case 16:
			weatherCode = "Heavy snow,大雪";
			break;
		case 17:
			weatherCode = "Snowstorm,暴雪";
			break;
		case 18:
			weatherCode = "Foggy,雾";
			break;
		case 19:
			weatherCode = "Ice rain,冻雨";
			break;
		case 20:
			weatherCode = "Duststorm,沙尘暴";
			break;
		case 21:
			weatherCode = "Light to moderate rain,小到中雨";
			break;
		case 22:
			weatherCode = "Moderate to heavy rain,中到大雨";
			break;
		case 23:
			weatherCode = "Heavy rain to storm,大到暴雨";
			break;
		case 24:
			weatherCode = "Storm to heavy storm,暴雨到大暴雨";
			break;
		case 25:
			weatherCode = "Heavy to severe storm,大暴雨到特大暴雨";
			break;
		case 26:
			weatherCode = "Light to moderate snow,小到中雪";
			break;
		case 27:
			weatherCode = "Moderate to heavy snow,中到大雪";
			break;
		case 28:
			weatherCode = "Heavy snow to snowstorm,大到暴雪";
			break;
		case 29:
			weatherCode = "Dust,浮尘";
			break;
		case 30:
			weatherCode = "Sand,扬沙";
			break;
		case 31:
			weatherCode = "Sandstorm,强沙尘暴";
			break;
		case 32:
			weatherCode = "Dense fog,浓雾";
			break;
		case 49:
			weatherCode = "Heavy dense fog,强浓雾";
			break;
		case 53:
			weatherCode = "Haze,霾";
			break;
		case 54:
			weatherCode = "Moderate haze,中度霾";
			break;
		case 55:
			weatherCode = "Severe haze,重度霾";
			break;
		case 56:
			weatherCode = "Hazardous haze,严重霾";
			break;
		case 57:
			weatherCode = "Heavy fog,大雾";
			break;
		case 58:
			weatherCode = "Extra-heavy dense fog,特强浓雾";
			break;
		case 99:
			weatherCode = "Unknown,无";
			break;
		case 301:
			weatherCode = "Rain,降雨";
			break;
		case 302:
			weatherCode = "Snow,降雪";
			break;
		default:
			weatherCode = "Sunny,晴";
			break;
		}
		return weatherCode;
	}

	/** 风向码 **/
	public String winCode(String windCode){
		String ddCode = "No wind,无持续风向";
		Double windCodes = Double.parseDouble(windCode);
		if(StringUtils.isEmpty(windCode)){
			ddCode = "No wind,无持续风向";
		}else if((windCodes>=0&&windCodes<=22.5)||(windCodes>337.5&&windCodes<=360)){
			ddCode = "North,北风";
		}else if(windCodes>22.5&&windCodes<=67.5){
			ddCode = "Northeast,东北风";
		}else if(windCodes>67.5&&windCodes<=112.5){
			ddCode = "East,东风";
		}else if(windCodes>112.5&&windCodes<=157.5){
			ddCode = "Southeast,东南风";
		}else if(windCodes>157.5&&windCodes<=202.5){
			ddCode = "South,南风";
		}else if(windCodes>202.5&&windCodes<=247.5){
			ddCode = "Southwest,西南风";
		}else if(windCodes>247.5&&windCodes<=292.5){
			ddCode = "West,西风";
		}else if(windCodes>292.5&&windCodes<=337.5){
			ddCode = "Northwest,西北风";
		}
		return ddCode;
	}
	
	/** 风速码 **/
	public String speedCode(String wSpeedCode){
		String ffCode = "微风";
		Double wSpeedCodes = Double.parseDouble(wSpeedCode);
		if(wSpeedCodes>=0&&wSpeedCodes<=5.5){
			ffCode = "微风";
		}else if(wSpeedCodes>5.5&&wSpeedCodes<=8.0){
			ffCode = "3-4 级";
		}else if(wSpeedCodes>8.0&&wSpeedCodes<=10.8){
			ffCode = "4-5 级";
		}else if(wSpeedCodes>10.8&&wSpeedCodes<=13.9){
			ffCode = "5-6 级";
		}else if(wSpeedCodes>13.9&&wSpeedCodes<=17.2){
			ffCode = "6-7 级";
		}else if(wSpeedCodes>17.2&&wSpeedCodes<=20.8){
			ffCode = "7-8 级";
		}else if(wSpeedCodes>20.8&&wSpeedCodes<=24.5){
			ffCode = "8-9 级";
		}else if(wSpeedCodes>24.5&&wSpeedCodes<=28.5){
			ffCode = "9-10 级";
		}else if(wSpeedCodes>28.5&&wSpeedCodes<=32.7){
			ffCode = "10-11 级";
		}else if(wSpeedCodes>32.7&&wSpeedCodes<=37.0){
			ffCode = "11-12 级";
		}
		return ffCode;
	}
}
